﻿using FluentNHibernate.Mapping;
using SimpleScrum.Core.Entities;

namespace SimpleScrum.Core.Mappings
{
    public class OrganizationMap : ClassMap<Organization>
    {
        public OrganizationMap()
        {
            Table("Organization");
            LazyLoad();
            Id(x => x.Id).Column("ID").GeneratedBy.GuidComb();
            Map(x => x.Name).Column("Name").Not.Nullable();
            Map(x => x.Description).Column("Description").Not.Nullable();
            References(x => x.Users).Column("UsersId").Cascade.All();
            HasMany(m => m.Projects).KeyColumn("OrganizationID").AsList(l => l.Column("ProjectIndex"));
        }
    }
}